#include<bits/stdc++.h>
using namespace std;
int i,j;
int n,d,t;
int Time[10010],finger[5]; 
int main()
{
	cin>>t;
	while(t--)
	{
		cin>>n>>d;
		memset(finger,0,sizeof(finger));
		for(i=1;i<=n;i++)
			cin>>Time[i];
		sort(Time+1,Time+n+1);
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=4;j++)
			{
				if(finger[j]<=(Time[i]-Time[i-1]))
				{
					for(int k=1;k<=j;k++)
						finger[k]=finger[k]-(Time[i]-Time[i-1])<=0?0:finger[k]-(Time[i]-Time[i-1]);
					finger[j]+=d;
					break;
				}
			}
			if(j>4)
			{
				cout<<"-1"<<endl;
				break;
			}
			else
			{
				cout<<j<<endl;
				break;
			}	
		}
	}
    return 0;
}

